/*
 * Copyright (c) 2008-2013 Haulmont. All rights reserved.
 * Use is subject to license terms, see http://www.cuba-platform.com/license for details.
 */

package com.haulmont.asu.entity;

import com.haulmont.chile.core.annotations.MetaProperty;
import com.haulmont.chile.core.annotations.NamePattern;
import com.haulmont.cuba.core.entity.StandardEntity;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * Author: Sergey42
 * Date: 14.10.13 12:37
 */
@Table(name = "EXT_COMMISSION_MEMBER")
@Entity(name = "ext$CommissionMember")
@NamePattern("%s|name")
public class CommissionMember extends StandardEntity {

    private static final long serialVersionUID = 6800343062728280875L;

    @ManyToOne
    @JoinColumn(name = "PERSON_ID")
    protected Person person;

    @ManyToOne
    @JoinColumn(name = "COMMISSION_ID")
    protected Commission commission;

    @ManyToOne
    @JoinColumn(name = "ROLE_ID")
    protected CommissionMemberRole role;

    @MetaProperty
    public String getName() {
        return person != null ? person.getName() : "badView";
    }

    public CommissionMemberRole getRole() {
        return role;
    }

    public void setRole(CommissionMemberRole role) {
        this.role = role;
    }

    public Commission getCommission() {
        return commission;
    }

    public void setCommission(Commission commission) {
        this.commission = commission;
    }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }
}
